package demo3;


import demo4.TestDemo;

public class TestDemo1 {
    // 判断二叉树是不是满二叉树
    static class TreeNode{
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val){
            this.val = val;
        }
    }
    //信息体 :
    //左树满
    //右树满
    //左树高度=右树高度

    static class Info{
        public boolean isFull;
        public int height;

        public Info(boolean isFull,int height){
            this.isFull = isFull;
            this.height = height;
        }
    }

    public static Info process2(TreeNode head){
        if(head==null) return new Info(true,0);
        Info leftInfo = process2(head.left);
        Info rightInfo = process2(head.right);
        int height = Math.max(leftInfo.height,rightInfo.height)+1;
        boolean isFull = true;
        if(!leftInfo.isFull){
            isFull = false;
        }
        if(!rightInfo.isFull){
            isFull = false;
        }
        if(leftInfo.height!= rightInfo.height){
            isFull = false;
        }
        return new Info(isFull,height);
    }


}
